package fun.tan90.easy.binlog.worker.handler;

import fun.tan90.easy.binlog.base.constants.EasyBinlogConstants;
import fun.tan90.easy.binlog.base.strategy.AbstractExecuteStrategy;
import fun.tan90.easy.binlog.worker.cache.BinaryLogClientKey;
import lombok.extern.slf4j.Slf4j;
import org.noear.socketd.transport.core.Entity;
import org.noear.socketd.transport.core.Message;
import org.noear.socketd.transport.core.entity.StringEntity;
import org.springframework.stereotype.Component;

/**
 * description TODO
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2023/12/15 19:42
 */
@Slf4j
@Component
public class WorkerMasterCodeHandler implements AbstractExecuteStrategy<Message, Entity> {

    @Override
    public String mark() {
        return EasyBinlogConstants.WORKER_RUNNING_MASTER_CODE;
    }

    @Override
    public Entity executeResp(Message message) {
        return new StringEntity(String.join(",", BinaryLogClientKey.BINARY_LOG_CLIENT_MAP.keySet()));
    }
}
